﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Elentok.Common.Wpf.ViewModels.Dialogs;
using System.Windows;
using Elentok.Common.Async;
using Elentok.Common.Wpf.Dialogs;
using System.Windows.Media;

namespace Elentok.Common.Wpf.Services
{
  /// <summary>
  /// Defines the services that opens the common dialogs
  /// </summary>
  public interface ICommonDialogsService
  {
    /// <summary>
    /// Opens the progress dialog and starts asynchronous task.
    /// </summary>
    /// <param name="task">The task.</param>
    /// <param name="showExceptionDialogOnError">if set to <c>true</c> show exception dialog on error.</param>
    void OpenProgressDialog(IAsyncTask task, bool showExceptionDialogOnError);
  }

  /// <summary>
  /// Opens the common dialogs
  /// </summary>
  public class CommonDialogsService : ICommonDialogsService
  {
    /// <summary>
    /// Opens the progress dialog and starts asynchronous task.
    /// </summary>
    /// <param name="task">The task.</param>
    /// <param name="showExceptionDialogOnError">if set to <c>true</c> show exception dialog on error.</param>
    public void OpenProgressDialog(IAsyncTask task, bool showExceptionDialogOnError)
    {
      var dialog = new ProgressDialog();
      dialog.Owner = Application.Current.MainWindow;
      dialog.Start(task, showExceptionDialogOnError);
    }
  }

}
